<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var countGoodTriplets = function(arr, a, b, c) {
				let n = arr.length;
				let res = 0;
				for (let i = 0; i < n; i++) {
					for (let j = i + 1; j < n; j++) {
						if (Math.abs(arr[i] - arr[j]) <= a) {
							for (let k = j + 1; k < n; k++) {
								if (Math.abs(arr[j] - arr[k]) <= b && Math.abs(arr[i] - arr[k]) <= c)
									res++;
							}
						}
					}
				}
				return res;
			};
			console.log(countGoodTriplets([3, 0, 1, 1, 9, 7], 7, 2, 3));
		</script>
	</body>
</html>
